package com.moyun.zbmy.zizhou.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.moyun.zbmy.zizhou.R;
import com.moyun.zbmy.zizhou.beans.AccountBean;
import com.moyun.zbmy.zizhou.ui.adapter.holder.AccountHolder;
import com.moyun.zbmy.zizhou.ui.adapter.holder.BaseAbsHolder;
import com.moyun.zbmy.zizhou.ui.util.IListShowData;

import java.util.List;

/**
 * 公众号列表
 */
public class AccountAdapter extends BaseHolderAbsAdapter<AccountBean, BaseAbsHolder<AccountBean>> {


    private Context context;
    private AccountAdapter.OnAccountClickListener accountClickListener;
    private AccountAdapter.OnAccountSubscribeClickListener subscribeClickListener;

    public AccountAdapter(Context context, List<AccountBean> list, AccountAdapter.OnAccountClickListener listener, AccountAdapter.OnAccountSubscribeClickListener subscribeClickListener) {
        super(context, list);
        this.context = context;
        this.accountClickListener = listener;
        this.subscribeClickListener = subscribeClickListener;
    }


    @Override
    public BaseAbsHolder<AccountBean> onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_account_list, parent, false);
        BaseAbsHolder holder = new AccountHolder(context, view, accountClickListener, subscribeClickListener);
        return holder;
    }


    public void addData(List<AccountBean> list) {
        int pos = getItemCount();
        if (null != list) {
            data.addAll(list);
        }
        if (pos > 0) {
            notifyItemRangeChanged(pos, getItemCount());
        }
    }


    @Override
    public int getItemViewType(int position) {
        return 0;//dataList.get(position).getDataViewType();
    }

    @Override
    public void onBindViewHolder(BaseAbsHolder<AccountBean> holder, int position) {
        super.onBindViewHolder(holder, position);
    }

//
//    @Override
//    public int getItemCount() {
//        return data.size();
//    }

    public interface OnAccountClickListener {
        void OnAccountClick(AccountBean bean);
    }

    public interface OnAccountSubscribeClickListener {
        void OnSubscribeClick(AccountBean bean);
    }
}
